#include <list>

//using namespace std;

//template <class SendType,class ParamType>
//class MyEventPublisher;

template <class SendType,class ParamType>
class MyEventHandler
{
public:
	virtual ~MyEventHandler(){}
	virtual void HandleEvent(SendType sender,ParamType param) = 0;
};


template <class SendType,class ParamType>
class MyEvent
{
public:
	virtual ~MyEvent(){}
	virtual void Register(MyEventHandler<SendType,ParamType>* handler) = 0;
	virtual void UnRegister(MyEventHandler<SendType,ParamType>* handler) = 0;
};

template <class SendType,class ParamType>
class MyEventActivator
{
public:
	virtual ~MyEventActivator(){}
	virtual void Invoke(SendType sender,ParamType param) = 0;
};

template <class SendType,class ParamType>
class MyEventPublisher : public MyEvent<SendType,ParamType>, public MyEventActivator<SendType,ParamType>
{
private:
	std::list<MyEventHandler<SendType,ParamType>* > listHandler;
public:
	void Register(MyEventHandler<SendType,ParamType>* handler)
	{
		listHandler.push_back(handler);
	}
	void UnRegister(MyEventHandler<SendType,ParamType>* handler)
	{
		listHandler.remove(handler);
	}
	void Invoke(SendType sender,ParamType param)
	{
		std::list<MyEventHandler<SendType,ParamType>* >::iterator ite = listHandler.begin();
		for(;ite != listHandler.end(); ++ite)
		{
			(*ite)->HandleEvent(sender,param);
		}
	}
	~MyEventPublisher()
	{
		
	}
};